package cn.itsource.pet.service.impl;

import cn.itsource.basic.domain.Point;
import cn.itsource.basic.service.impl.BasicServiceImpl;
import cn.itsource.basic.util.DistanceUtil;
import cn.itsource.org.domain.Shop;
import cn.itsource.org.service.IShopService;
import cn.itsource.pet.domain.Pet;
import cn.itsource.pet.domain.PetDetail;
import cn.itsource.pet.domain.SearchMasterMsg;
import cn.itsource.pet.mapper.PetDetailMapper;
import cn.itsource.pet.mapper.PetMapper;
import cn.itsource.pet.service.IPetService;
import cn.itsource.pet.service.ISearchMasterMsgService;
import cn.itsource.product.domain.ProductDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PetServiceImpl extends BasicServiceImpl<Pet> implements IPetService {
    @Autowired
    private PetMapper petMapper;
    @Autowired
    private PetDetailMapper petDetailMapper;

    @Override
    public void add(Pet pet) {
        //类型
        pet.setType_id(1L);
        pet.setCreatetime(new Date());
        Shop shop = new Shop();
        shop.setId(27L);
        pet.setShop(shop);
        //先保存产品对象 返回主键
        petMapper.save(pet);
        //
        PetDetail detail = pet.getDetail();
        //设置关联对象
        //detail.setProduct_id(product.getId());
        detail.setPet_id(pet.getId());
        //保存产品详情
        petDetailMapper.save(detail);
    }
}
